package com.lc.login.mvp.model;

import android.app.Application;

import com.google.gson.Gson;

import javax.inject.Inject;

import com.lc.baselib.net.manager.IRepositoryManager;
import com.lc.baseres.base.BaseJson;
import com.lc.baseres.base.BaseModel;
import com.lc.baseres.dagger.scope.ActivityScope;
import com.lc.login.bean.UserSimpleInfo;
import com.lc.login.mvp.contract.LoginContract;
import com.lc.login.retrofit.LoginService;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;


@ActivityScope
public class LoginModel extends BaseModel implements LoginContract.Model {

    @Inject
    public LoginModel(IRepositoryManager repositoryManager, Application application) {
        super(repositoryManager);
        this.mApplication = application;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mApplication = null;
    }

    @Override
    public Observable<BaseJson<UserSimpleInfo>> checkLogin(String name, String password) {
        return mRepositoryManager.obtainRetrofitService(LoginService.class)
                .checkLogin(name, password)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}